package MyFile;

import java.io.File;
import java.io.IOException;

public class demo3 {
    public static void main(String[] args) throws IOException {
        File file = new File("D:/");
        recursion(file,"WeChat.exe");

    }
    public static void recursion(File file,String name) throws IOException {
        if (file == null || !file.exists() || file.isFile()){
            /*System.out.println("file 不合法！！！");*/
            return;
        }

        File[] files = file.listFiles();
        if ( files != null && files.length > 0){
            for (int i = 0; i < files.length; i++) {
                File tempFile = files[i];
                if (tempFile.isFile() && tempFile.getName().equals(name)){
                    System.out.println( "找到啦 ==>" + tempFile.getAbsoluteFile() + "启动！！！");
                    Runtime runtime = Runtime.getRuntime();
                    runtime.exec(name);
                    return;
                }else {
                    recursion(tempFile,name);
                }
            }
        }
        /*System.out.println("啥也没有！");*/
    }

}
